package overrideoverwrite;

import java.util.Date;

/**
 * @ClassName Employee
 * @Date 2024/11/27 14:45 47
 * @Author Jack Chen
 * @Description serenity-cucumber-auto-project-jack
 * @Version 1.0
 */

public class Employee implements Cloneable {
    private String name;
    private double salary;
    private Date hireDate;
    public Employee(String name, double salary) {
        this.name = name;
        this.salary = salary;
        this.hireDate = new Date();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public Date getHireDate() {
        return hireDate;
    }

    public void setHireDate(Date hireDate) {
        this.hireDate = hireDate;
    }

    public String toString(){
        return "Employee[Name: " + name + " Salary: " + salary + " Hire Date: " + hireDate+"]";
    }

    public Employee clone() throws CloneNotSupportedException {
        //浅拷贝
        return (Employee) super.clone();

        //深拷贝
//        Employee cloned = (Employee) super.clone();
//        try {
//            Thread.sleep(3000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
//        cloned.hireDate = (Date) hireDate.clone();
//        return cloned;
    }
}
